package com.dc.wifi.main.adapter

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.dc.wifi.main.ui.fragment.HomeFragment
import com.dc.wifi.main.ui.fragment.MallFragment
import com.dc.wifi.main.ui.fragment.MineFragment


/**
 * @Author HL
 * @Date 2024/2/14 15:45
 * @Version 1.0
 */
class BottomTabAdapter(fragmentActivity : FragmentActivity, private val count : Int)
    : FragmentStateAdapter(fragmentActivity) {
    override fun getItemCount(): Int {
        return count
    }

    /**
     * position 是每个 Fragment 对应的下标
     */
    override fun createFragment(position: Int): Fragment {
        return when(position){
            0 -> HomeFragment.createFragment(Bundle())
            1 ->MallFragment.createFragment(Bundle())
            2 -> MineFragment.createFragment(Bundle())
            else -> HomeFragment.createFragment(Bundle())
        }
    }
}